package com.juc.phaser.phaser15;

import java.util.concurrent.Phaser;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class ThreadA extends Thread{
	/**
	 * awaitAdvanceInterruptibly(int phase,long timeout, TimeUnit unit)
	 */
	private Phaser phaser;
	
	
	public ThreadA(Phaser phaser) {
		super();
		this.phaser= phaser;
	}
	
	@Override
	public void run() {
		try {
			System.out.println(Thread.currentThread().getName() + " A1 begin = " +System.currentTimeMillis());
		    phaser.awaitAdvanceInterruptibly(0, 5, TimeUnit.SECONDS);
			System.out.println(Thread.currentThread().getName() + " A1 end = " +System.currentTimeMillis());
		} catch (InterruptedException e) {
			e.printStackTrace();
		} catch (TimeoutException e) {
			e.printStackTrace();
		}
	}
	
	

}
